<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>个人中心</title>
    <script type="text/javascript" src="js/jquery-2.1.0.js"></script>
</head>
<script>

    $(function () {

        $("#logout").click(function () {
            $.ajax("/user/logout",{
                type:"get",
                data:{},
                success:function(data){
//                      在这里注册成功后跳转页面
                    console.log(data);
                    window.location.href="login.html";
                },
                error:function(){
                }
            })
        });

        $.ajax("/user/borrowInfo",{
            type:"get",
            data:{},
            success:function(data){
                console.log(data);

                var dataObj = eval('('+data+')');
                var div = document.getElementById('table');
                $('.tr1').remove();
                for (var i = 0;i < dataObj.length;i++){
                    var newDiv = document.createElement('tr');
                    div.appendChild(newDiv);
                    newDiv.setAttribute('class', 'tr1');
                    newDiv.innerHTML = "<td>"+dataObj[i].bookName+"</td>"+
                        "<td>"+dataObj[i].type+"</td>"+
                        "<td>"+dataObj[i].publishTime+"</td>"+
                        "<td>"+dataObj[i].returnTime+"</td>";


                }
            },
            error:function(){

            }
        });

        $.ajax("/user/userName",{
            type:"get",
            data:{},
            success:function(data){
                console.log(data);

                var dataObj = eval('('+data+')');
                $('#person').text(dataObj.username);
            },
            error:function(){

            }
        });

    })
</script>
<body>
<div style="position: absolute;right:10px;margin-right: 40px;top: 10px;">
    <a  href="librarylist.html" style="cursor: pointer;text-decoration: none">图书列表</a>&nbsp;&nbsp;<span id="logout" style="cursor: pointer">登出</span>
</div>
<hr style="margin-top: 40px"/>
<div style="position: absolute;left: 450px;text-align: center">
    <h1>个人中心</h1>
    <table border="1" id="table" width="400px">
        <tr>
            <td colspan="4">欢迎您：<span id="person"></span></td>
        </tr>
        <tr>
            <td colspan="4">您借阅的图书信息：</td>
        </tr>
        <tr>
            <th>名字</th>
            <th>类型</th>
            <th>出版时间</th>
            <th>归还时间</th>
        </tr>
    </table>
</div>
</body>
</html>